﻿namespace ExamV5
{
    using System;
    using System.Configuration;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;

    public class FrmFindPwd : Page
    {
        protected Button butClose;
        protected Button butDefault;
        protected DropDownList DDLDept;
        protected DropDownList DDLGWLevel;
        protected DropDownList DDLGWName;
        protected DropDownList DDLUPDept;
        protected DropDownList DDLUserSex;
        protected DropDownList DDLWorker;
        protected HtmlForm form1;
        private PublicFun publicFun_0 = new PublicFun();
        protected TextBox txtMoveTel;
        protected TextBox txtUserCode;
        protected TextBox txtUserName;
        protected TextBox txtUserSFZH;

        protected void butDefault_Click(object sender, EventArgs e)
        {
            string str = this.publicFun_0.CheckString(this.txtUserSFZH.Text.Trim());
            string str2 = this.publicFun_0.CheckString(this.txtMoveTel.Text.Trim());
            string str3 = this.publicFun_0.CheckString(this.DDLGWName.SelectedItem.Value.Trim());
            string str4 = this.publicFun_0.CheckString(this.DDLGWLevel.SelectedItem.Value.Trim());
            string strSql = "select UserCode from UserInfo where UserLevel='A' and UserSex='" + this.publicFun_0.CheckString(this.DDLUserSex.SelectedItem.Text) + "' and UserCode='" + this.publicFun_0.CheckString(this.txtUserCode.Text.Trim()) + "' and UserName='" + this.publicFun_0.CheckString(this.txtUserName.Text.Trim()) + "'  and DeptID=" + this.publicFun_0.CheckString(this.DDLDept.SelectedItem.Value) + " and Worker='" + this.publicFun_0.CheckString(this.DDLWorker.SelectedItem.Text) + "' ";
            if (str.Trim() != "")
            {
                strSql = strSql + " and UserSFZH='" + str + "'";
            }
            if (str2.Trim() != "")
            {
                strSql = strSql + " and HandCombNO='" + str2 + "'";
            }
            if (str3.Trim() != "")
            {
                strSql = strSql + " and UserGWName='" + str3 + "'";
            }
            if (str4.Trim() != "")
            {
                strSql = strSql + " and UserGWLevel='" + str4 + "'";
            }
            if (this.publicFun_0.GetValues(strSql, "UserCode") != "")
            {
                this.publicFun_0.ExecuteSql("update UserInfo set UserPwd='670B14728AD9902AECBA' where UserCode='" + this.publicFun_0.CheckString(this.txtUserCode.Text.Trim()) + "'");
                base.Response.Write("<script>alert('您的密码已经初始化为六个零，即：000000');window.close();</script>");
            }
            else
            {
                base.Response.Write("<script>alert('对不起,您输入的信息与注册时信息不相符,无法取回密码！')</script>");
            }
        }

        protected void DDLUPDept_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.DDLDept.Items.Clear();
            this.publicFun_0.LoadDeptInfo(this.DDLDept, this.DDLUPDept.SelectedItem.Value, "admin", "B");
            if (this.DDLDept.Items.Count != 0)
            {
                this.DDLDept.SelectedIndex = -1;
                ListItem item2 = new ListItem("--请选择--", "0");
                this.DDLDept.Items.Insert(0, item2);
            }
            else
            {
                ListItem item = new ListItem(this.DDLUPDept.SelectedItem.Text, this.DDLUPDept.SelectedItem.Value);
                this.DDLDept.Items.Add(item);
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            this.Page.Title = ConfigurationManager.ConnectionStrings["ProTitle"].ConnectionString;
            if (!base.IsPostBack)
            {
                base.Response.Cache.SetCacheability(HttpCacheability.NoCache);
                base.Response.Cache.SetNoStore();
                if (this.publicFun_0.ReturnPaperData() != "Yes")
                {
                    base.Response.Write("<script>alert('此版本暂未授权,请与管理员联系！')</script>");
                }
                else
                {
                    this.DDLUPDept.DataTextField = "DeptName";
                    this.DDLUPDept.DataValueField = "ID";
                    this.DDLUPDept.DataSource = this.publicFun_0.RetrunDataView("select ID,DeptName from DeptInfo where UPID=0  order by SortInfo,ID");
                    this.DDLUPDept.DataBind();
                    this.DDLUPDept.SelectedIndex = -1;
                    this.DDLDept.SelectedIndex = -1;
                    ListItem item = new ListItem("--请选择--", "0");
                    this.DDLDept.Items.Insert(0, item);
                    this.DDLUPDept.Items.Insert(0, item);
                    this.DDLWorker.DataTextField = "ParmName";
                    this.DDLWorker.DataValueField = "ParmValue";
                    this.DDLWorker.DataSource = this.publicFun_0.RetrunDataView("select ParmName,ParmValue from SysParmInfo where ParmMemo='Worker'");
                    this.DDLWorker.DataBind();
                    ListItem item2 = new ListItem("--请选择--", "0");
                    this.DDLWorker.Items.Add(item2);
                    this.DDLWorker.Items.FindByValue("0").Selected = true;
                    this.DDLGWName.DataTextField = "ParmName";
                    this.DDLGWName.DataValueField = "ParmValue";
                    this.DDLGWName.DataSource = this.publicFun_0.RetrunDataView("select ParmName,ParmValue from SysParmInfo where ParmMemo='GWName'");
                    this.DDLGWName.DataBind();
                    ListItem item3 = new ListItem("--请选择--", "");
                    this.DDLGWName.Items.Add(item3);
                    this.DDLGWName.Items.FindByValue("").Selected = true;
                }
            }
        }
    }
}

